﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////
// Reviewed

#pragma once


#include "Vector2d.h" 
#include "GbmpConstants.h"
#include "GcmpApiDeclaration.h"

namespace gcmp
{
    /// \brief  二维坐标系定义
    ///
    /// 
    class GCMP_MATH_INTERFACE_EXPORT Coordinate2d
    {
    public:
        DEFINE_VISUAL_TYPE_DOUBLE()

    public:
        /// \brief   由原点和X轴生成坐标系
        ///
        /// \param pos    原点
        /// \param dirX   X轴 
        /// \return  构建的坐标系
        static Coordinate2d CreateFromAxis(const Vector2d& pos, const Vector2d& dirX );

        /// \brief   由原点，X轴构建坐标系
        ///
        /// \param pos   原点
        /// \param dirX  X轴 
        /// \return   true: 成功， false: 失败 
        bool Set(const Vector2d& pos, const Vector2d& dirX);

        /// \brief   获取坐标系原点
        ///
        /// \return  坐标系原点
        const Vector2d& GetOrigin() const;
        
        const Vector2d& GetX() const;

        const Vector2d& GetY() const;


    public :

        /// \brief  默认的构造函数
        /// 
        Coordinate2d();

        /// \brief    构造函数，由X轴，和原点生成坐标系
        ///
        /// \param pos   原点
        /// \param unitDirX  X轴 
        ///
        Coordinate2d(const Vector2d& pos, const Vector2d& unitDirX );

        /// \brief  拷贝构造函数
        ///
        /// \param src 输入坐标系
        /// 
        Coordinate2d(const Coordinate2d& src);

        /// \brief  获取X轴
        ///
        /// \return X轴
        const Vector2d& X() const;

        /// \brief  获取Y轴
        ///
        /// \return Y轴
        const Vector2d& Y() const;

        /// \brief  获取原点
        ///
        /// \return 原点
        const Vector2d& Origin() const;

        /// \brief 把坐标系对象按照规定格式字符串输出
        ///
        /// \return 字符串
        std::wstring GetStringForDebug() const;

    private:

        ///坐标系的原点
        Vector2d m_origin;

        ///坐标系的X轴
        Vector2d m_x;

        ///坐标系的Y轴
        Vector2d m_y;

    };

} // namespace




